package com.pcj.blog.interceptor;/**
 * @param
 * @author pcj
 * @date 2021/12/27 15:41
 * @return
 */

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器  防止未登录直接访问后台管理
 * @className WebConfig
 * @author pengcj
 * @date 2021/12/27 15:41
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin/login")
                .excludePathPatterns("/admin");
    }
}
